package cn.edu.nju.software.sym.data;

import java.util.ArrayList;

public class PlayList {
	private ArrayList<Song> playlist;

	// constructor
	public PlayList() {
		playlist = new ArrayList<Song>();
	}

	// add the song to the playlist
	public boolean add(Song song) {
		return this.playlist.add(song);

	}

	public void add(int index, Song song) {
		this.playlist.add(index, song);
	}

	// remove the song form the playlist
	public boolean remove(Song song) {
		return this.playlist.remove(song);
	}

	// remove the song by the title of the song
	public boolean remove(String title) {
		int limit = playlist.size();
		for (int i = 0; i < limit; i++) {
			if (playlist.get(i).getTitle().equalsIgnoreCase(title)) {
				playlist.remove(i);
				return true;
			}
		}
		return false;
	}
	
	public Song remove(int index){
		return this.playlist.remove(index);
	}

	public ArrayList<Song> getPlaylist() {
		return playlist;
	}

	public void setPlaylist(ArrayList<Song> playlist) {
		this.playlist = playlist;
	}

}
